package com.liwy3.test.api;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertiesPropertySource;

import java.util.Properties;

/**
 * @author weiye.li
 * @date 2023/2/13
 */
public class EnvConfigEnvironmentProcessor implements EnvironmentPostProcessor, Ordered {


    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {

        Properties properties = new Properties();
        properties.setProperty("dmall.admiral.localPropsFirst", "true");
        properties.setProperty("ADMIRAL_APP_NAME", "aldi");
        properties.setProperty("ADMIRAL_SERVER_DOMAIN", "testadmiral.server.api.inner-dmall-os.cn");
        properties.setProperty("ADMIRAL_CLIENT_GROUP", "blue");
        PropertiesPropertySource propertiesPropertySource = new PropertiesPropertySource("DMC", properties);
        environment.getPropertySources().addFirst(propertiesPropertySource);

    }

    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE - 1;
    }
}
